<?php
include_once 'config.php';
include_once 'database/dbmysql.php';

header('Content-type: text/html; charset='.FTsso_CHARSET);
//$querystring=$_SERVER['QUERY_STRING'];
//$get = explode('-' , $querystring);
//print_r($_POST);
$mysqldb  =  new DB(DB_HOST, DB_USER, DB_PW, DB_NAME);
$userInfo = array();
if($_POST['username'] == '游客'){
	//$sqlSightseer = 'select u.*, g.grouptitle,g.regulars,g.default,g.type,g.creditslower,g.creditshigher,g.stars,g.color,g.groupavatar from '.DB_TABLEPRE.'user_'.substr(md5($_POST['username']), 0, 2).' u,'.DB_TABLEPRE.'usergroup g where  u.username='.$_POST['username'].' and g.groupid=1';
	$sqlSightseer = 'select * from '.DB_TABLEPRE.'usergroup g where g.groupid=1';
	
	$userInfo = $mysqldb->GetOne($sqlSightseer);
	$userInfo['uid']      = 0     ;
	$userInfo['username'] = '游客';
}else{
	//检查用户是否登陆
	$sqlIsLogin = "SELECT * FROM `sso_onlineuser` WHERE  `username` = '".$_POST['username']."'";
	
	$loginFlag = $mysqldb->GetOne($sqlIsLogin);
	
	if($loginFlag == 0){
		$userInfo = array ( 'uid' => 0,
							'username' => '游客', 
							'groupid' => 1,
							'grouptitle' => '匿名用户',
							'regulars' => 'index-default|index-settheme|category-default|category-ajax|category-view|category-letter|list-letter|list-default|list-recentupdate|list-popularity|list-focus|doc-view|doc-innerlink|doc-summary|doc-editor|comment-view|comment-report|comment-oppose|comment-aegis|edition-list|edition-view|edition-compare|search-default|search-fulltext|search-kw|search-tag|list-weekuserlist|list-allcredit|list-rss|doc-random|doc-vote|doc-cooperate|gift-default|gift-view|gift-search|gift-apply|pic-piclist|pic-view|pic-ajax|pic-search|user-register|user-login|user-check|user-checkusername|user-checkcode|user-checkpassword|user-checkoldpass|user-checkemail|user-getpass|user-code|user-space|user-clearcookies|synonym-view|passport_client-login|passport_client-logout|archiver-default|archiver-list|archiver-view|datacall-js|search-agent|search-agent',
							'default' => 'index-default|index-settheme|category-default|category-ajax|category-view|category-letter|list-letter|list-default|list-recentupdate|list-popularity|list-focus|doc-view|doc-innerlink|doc-summary|doc-editor|comment-view|comment-report|comment-oppose|comment-aegis|edition-list|edition-view|edition-compare|search-default|search-fulltext|search-kw|search-tag|list-weekuserlist|list-allcredit|list-rss|doc-random|doc-vote|doc-cooperate|gift-default|gift-view|gift-search|gift-apply|pic-piclist|pic-view|pic-ajax|pic-search|user-register|user-login|user-check|user-checkusername|user-checkcode|user-checkpassword|user-checkoldpass|user-checkemail|user-getpass|user-code|user-space|user-clearcookies|synonym-view|passport_client-login|passport_client-logout|archiver-default|archiver-list|archiver-view|datacall-js|search-agent|search-agent',
							'type' => 1,
							'creditslower' => 0,
							'creditshigher' => 0,
							'stars' => 0,
							'color' => '',
							'groupavatar' =>'' );
	}else{
		$sqlUserInfo = 'select u.*, g.* from '.DB_TABLEPRE.'user_'.substr(md5($_POST['username']), 0, 2).' u,'.DB_TABLEPRE.'usergroup g where  u.username=\''.$_POST['username'].'\' and u.groupid=g.groupid';
		
		$userInfo = $mysqldb->GetOne($sqlUserInfo);
	}
}
echo json_encode($userInfo);
//echo json_encode($_POST);
?>
